#ifndef CONFIRM_VIEW_HPP
#define CONFIRM_VIEW_HPP 1

#include "MacArrayMessage.hpp"
#include "HistoryDigest.hpp"
#include "../Parameters.hpp"

namespace BFT
{
	namespace order
	{
		namespace messages
		{
			class ConfirmView: public BFT::messages::MacArrayMessage
			{
				public:
				
				ConfirmView(uint32_t _view, uint32_t _seqno,
					    boost::shared_ptr<BFT::messages::HistoryDigest> _hd,
					    uint32_t _sendingReplica);
				
				ConfirmView(boost::shared_ptr<char> _bytes, int _bytes_size);
				
				bool matches(boost::shared_ptr<BFT::order::messages::ConfirmView> _other_cv);
				
				bool equals(boost::shared_ptr<BFT::order::messages::ConfirmView> _other_cv);
				
				uint32_t getSeqNo(); //inlined
				uint32_t getViewNo(); //inlined
				uint32_t getSendingReplica(); //inlined
				boost::shared_ptr<BFT::messages::HistoryDigest> getHistory(); //inlined
				
				protected:
				
				uint32_t seqNo;
				uint32_t view;
				boost::shared_ptr<BFT::messages::HistoryDigest> history;
				
				private:
				
				static uint32_t computeSize();
			};
			
			inline uint32_t ConfirmView::getSeqNo() {return seqNo;}
			inline uint32_t ConfirmView::getViewNo() {return view;}
			inline boost::shared_ptr<BFT::messages::HistoryDigest> ConfirmView::getHistory() {return history;}
			inline uint32_t ConfirmView::getSendingReplica() {return getSender();}
		}
	}
}

#endif
